
#include <iostream>
#include "GxBase/GxPtr.h"
#include "GxBase/GxCustomType.h"
#include "GxBase/utilParam.h"
using namespace std;
using namespace gx::base;

class Test : public CGxRefBase
{
public:
    Test()
    {
        printf("Test C\n");
        a = 0;
    }
    ~Test(){printf("Test D\n");}

    void Print()
    {
        //printf("count %d\n", m_uCount);
    }
    void Set(int aa)
    {
        a = aa;
    }
    void Get()
    {
        printf("Test a %d\n", a);
    }

    int      a;

private:

};

template<class T>
CGxPtr<CGxCustomPtr<T>> hehe(CGxPtr<CGxCustomPtr<T>> gxpTest)
{
    u8* pu8;
    gxpTest->GetPtr(&pu8);
    //printf("%s\n", (char*)pu8);
    return gxpTest;
}

int main()
{
    CGxPtr<Test> p = new Test;
    p->Set(456);
    CGxPtr<IGxParam> pParam;
    CreateGxParam(pParam);
    SetParam(pParam, String("chenliping"), 123);
    u32 aa = 0;
    GetParam(pParam, String("chenliping"), aa);
    cout<<aa<<endl;

    CGxPtr<IGxParam> pParam1;
    CreateGxParam(pParam1);
    SetParam(pParam1, String("guoxian"), pParam);
    pParam = NULL;
    GetParam(pParam1, String("guoxian"), pParam);
    aa = 0;
    GetParam(pParam, String("chenliping"), aa);
    cout<<aa<<endl;


    p->Print();
    if (SetParam(pParam, String("chenliping1"), p))
    {
        p->Print();
    }
    p = NULL;
    GetParam(pParam, String("chenliping1"), p);
    p->Print();
    p->Get();

    system("pause");
    return 0;
}